#ifndef __CMD_LS_H_
#define __CMD_LS_H_
#include <sys/stat.h>
#include "cmd_handle.h"
#include <stdbool.h>

#define SZ_LS_NAME 64
#define SZ_LS_TIME 32
#define SZ_LS_PERMISSION 10
#define SZ_LS_LINK_CONTENT 64

// 文件属性
typedef struct file_attribute
{
    /* data */
    struct stat f_attr_stat_info;

    char f_attr_type;
    char f_attr_uname[SZ_LS_NAME];
    char f_attr_gname[SZ_LS_NAME];
    char f_attr_mtime[SZ_LS_TIME];
    char f_attr_permission[SZ_LS_PERMISSION];
    char f_attr_name[SZ_LS_NAME];
    char f_attr_link_content[SZ_LS_LINK_CONTENT];
} file_attribute_t;

int cmd_ls_execute(cmd_t *pcmd);
int cmd_list_directory(char *dirpath);
void make_path_ls(char *path, char *dirpath, char *filename);

int get_file_attr(struct file_attribute *pattr, const char *path, const char *name, bool islink);

int get_file_type_ls(struct file_attribute *pattr);
int get_file_permission(struct file_attribute *pattr);
void get_file_uname(struct file_attribute *pattr);
void get_file_gname(struct file_attribute *pattr);
void get_file_last_modify_time(struct file_attribute *pattr);

void show_file_attributes(struct file_attribute *pattr);

#endif